<?php
/*
 * TuanTM
 * TODO:
 *      * To control index.php of community page
 *      * Access via : public\community\index
 * 
 */
class Community_IndexController extends Zend_Controller_Action
{

    public function init()
    {
        // Khởi tạo các thẻ [Lĩnh vực tìm kiếm]
        $category=new Admin_Model_MCategory();
        $bookCategory=$category->getAllCategories(array("_id","name"));
        $this->view->category=$bookCategory;        

        // Cài đặt thông tin đăng nhập
        $mySession=new Zend_Session_Namespace();
        if(isset ($mySession->uid) && isset($mySession->username))
        {
            $this->view->username=$mySession->username;
            $this->view->uid=$mySession->uid;

            $userModel=new Personal_Model_MUser();
            $this->view->userinfo=$userModel->getInfoBasic($mySession->uid);
        }
        
    }

    public function indexAction()
    {
        $this->_helper->layout()->setLayout('layout_community');

        // event
        $eventModel=new Community_Model_MEvent();
        $event=$eventModel->getEvents($total, 1, 5);
        $this->view->event=$event;

        // story
        $storyModel=new Community_Model_MStory();
        $story=$storyModel->getStories($total, 1, 5);
        $this->view->story=$story;

        // bookcomment
        $commentModel=new Community_Model_MBookComment();
        $comment=$commentModel->getComments($total, 1, 5);
        $this->view->comment=$comment;
    }
}

